#!/usr/bin/env bash
service_name='pt-core-reports'
cluster_name='ptadmin-automation-ec2'
ecs_service_name='src-pt-core-reports'

docker rmi -f ptadmin/${service_name} 599885534814.dkr.ecr.us-east-2.amazonaws.com/${service_name} || (echo "no image found!!!"; exit) \
&& docker build . -t ptadmin/${service_name} && docker tag ptadmin/${service_name}:latest 599885534814.dkr.ecr.us-east-2.amazonaws.com/${service_name}:latest \
&& $(aws ecr get-login --no-include-email --region us-east-2) \
&& docker push 599885534814.dkr.ecr.us-east-2.amazonaws.com/${service_name}:latest \
&& aws ecs update-service --cluster ${cluster_name} --service ${ecs_service_name} --force-new-deployment